package thread.java20221124;

/**
 * 使用Thread来创建线程
 */
class MyThread extends Thread {
    @Override
    public void run() {
        while (true){
            System.out.println(11);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class MyThread2 extends Thread {
    @Override
    public void run() {
        while (true){
            System.out.println(22);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
public class Demo1 {
    public static void main(String[] args) {
        Thread thread = new MyThread();
        Thread thread2 = new MyThread2();
        thread.start();
        thread2.start();
    }
}
